<?php

namespace common\models\credit_app_tables;

use Yii;

/**
 * This is the model class for table "{{%member}}".
 *
 * @property integer $u_id
 * @property string $u_code
 * @property string $u_name
 * @property string $u_password
 * @property string $u_salt
 * @property integer $u_role
 * @property string $u_realname
 * @property string $u_dp_type
 * @property integer $u_dp_id
 * @property string $u_scope
 * @property integer $u_auditlevel
 * @property string $u_mobile
 * @property string $u_job
 * @property string $u_addr
 * @property string $u_idcard
 * @property string $u_sex
 * @property string $u_birthday
 * @property string $u_culture
 * @property string $u_tel
 * @property string $u_qq
 * @property string $u_info
 * @property string $u_bank
 * @property string $u_avatar
 * @property integer $u_addtime
 * @property string $u_status
 */
class Member extends \yii\db\ActiveRecord
{
    const DP_TYPE_DOT = 'dot';
    const DP_TYPE_DP= 'dp';
    const DP_TYPE_RG= 'rg';
    public static function getDpType()
    {
        return [
            self::DP_TYPE_DOT=>'网点',
            self::DP_TYPE_DP=>'部门',
            self::DP_TYPE_RG=>'大区',
        ];
    }

    const SCOPE_USER = '用户级';
    const SCOPE_DP = '部门级';
    const SCOPE_COMP = '单位级';
    public static function getScope()
    {
        return [
            self::SCOPE_USER => '用户级',
            self::SCOPE_DP => '部门级',
            self::SCOPE_COMP => '单位级',
        ];
    }

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%member}}';
    }

    /**
     * @return \yii\db\Connection the database connection used by this AR class.
     */
    public static function getDb()
    {
        return Yii::$app->get('db_app');
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['u_code', 'u_name', 'u_password', 'u_salt', 'u_realname', 'u_auditlevel', 'u_mobile', 'u_job', 'u_addr', 'u_idcard', 'u_sex', 'u_birthday', 'u_culture', 'u_tel', 'u_qq', 'u_info', 'u_bank', 'u_avatar', 'u_addtime'], 'required'],
            [['u_role', 'u_dp_id', 'u_auditlevel', 'u_addtime'], 'integer'],
            [['u_dp_type', 'u_scope', 'u_bank', 'u_status'], 'string'],
            [['u_code', 'u_realname', 'u_job', 'u_tel', 'u_avatar'], 'string', 'max' => 30],
            [['u_name', 'u_password'], 'string', 'max' => 50],
            [['u_salt', 'u_sex', 'u_culture'], 'string', 'max' => 10],
            [['u_mobile'], 'string', 'max' => 11],
            [['u_addr'], 'string', 'max' => 100],
            [['u_idcard'], 'string', 'max' => 18],
            [['u_birthday', 'u_qq'], 'string', 'max' => 20],
            [['u_info'], 'string', 'max' => 200],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'u_id' => Yii::t('app', 'U ID'),
            'u_code' => Yii::t('app', '工号代码'),
            'u_name' => Yii::t('app', '账户名称'),
            'u_password' => Yii::t('app', '密码'),
            'u_salt' => Yii::t('app', '校验附加码'),
            'u_role' => Yii::t('app', '所属角色'),
            'u_realname' => Yii::t('app', '用户真实姓名'),
            'u_dp_type' => Yii::t('app', '部门ID dot 网点 dp 部门 rg大区'),
            'u_dp_id' => Yii::t('app', '部门'),
            'u_scope' => Yii::t('app', '权限等级'),
            'u_auditlevel' => Yii::t('app', '审核级别 对应setting_audit表数据'),
            'u_mobile' => Yii::t('app', '手机号'),
            'u_job' => Yii::t('app', '岗位职务'),
            'u_addr' => Yii::t('app', '地址'),
            'u_idcard' => Yii::t('app', '身份证号'),
            'u_sex' => Yii::t('app', '性别'),
            'u_birthday' => Yii::t('app', '生日'),
            'u_culture' => Yii::t('app', '文化程度'),
            'u_tel' => Yii::t('app', '电话'),
            'u_qq' => Yii::t('app', 'QQ'),
            'u_info' => Yii::t('app', '备注'),
            'u_bank' => Yii::t('app', '授权银行'),
            'u_avatar' => Yii::t('app', '头像'),
            'u_addtime' => Yii::t('app', '加入时间'),
            'u_status' => Yii::t('app', 'U Status'),
        ];
    }
}
